package scanner

type ScanOption struct {
	Async          bool     // 是否异步
	QueueLen       int      // 队列长度
	Exts           []string // 文件后缀
	ExcludeExts    []string // 排除的文件后缀
	Paths          []string // 文件夹路径
	HandleQueueLen int      // 处理队列长度

	IgnoreHidden bool // 是否忽略隐藏文件

	CacheDir   string // 缓存目录
	ThumbDir   string // 缩略图相对缓存的目录(默认: thumb)
	PreviewDir string // 预览视频相对缓存目录(默认: preview)

	GenThumb   bool // 是否生成缩略图
	GenPreview bool // 是否生成预览视频
}

func defaultScanOption() *ScanOption {
	return &ScanOption{
		QueueLen:       1,
		Exts:           []string{},
		ExcludeExts:    []string{},
		Paths:          []string{},
		HandleQueueLen: 10,
		IgnoreHidden:   true,
		CacheDir:       "cache",
		ThumbDir:       "thumb",
		PreviewDir:     "preview",
		GenThumb:       false,
		GenPreview:     false,
	}
}

type Option func(*ScanOption)

func WithExts(exts []string) Option {
	return func(o *ScanOption) {
		o.Exts = exts
	}
}
func WithExcludeExts(exts []string) Option {
	return func(o *ScanOption) {
		o.ExcludeExts = exts
	}
}
func WithPaths(paths ...string) Option {
	return func(o *ScanOption) {
		o.Paths = paths
	}
}
func WithIgnoreHidden(ignore bool) Option {
	return func(o *ScanOption) {
		o.IgnoreHidden = ignore
	}
}
func WithCacheDir(dir string) Option {
	return func(o *ScanOption) {
		o.CacheDir = dir
	}
}
func WithThumbDir(dir string) Option {
	return func(o *ScanOption) {
		o.ThumbDir = dir
	}
}
func WithPreviewDir(dir string) Option {
	return func(o *ScanOption) {
		o.PreviewDir = dir
	}
}
func WithGenThumb() Option {
	return func(o *ScanOption) {
		o.GenThumb = true
	}
}
func WithGenPreview() Option {
	return func(o *ScanOption) {
		o.GenPreview = true
	}
}

func WithAsync() Option {
	return func(o *ScanOption) {
		o.Async = true
	}
}
